package com.nineclock.attendance.controller;

import com.nineclock.attemdamce.AttendPunchControllerApi;
import com.nineclock.attendance.dto.AttendPunchDTO;
import com.nineclock.attendance.dto.AttendPunchUserWholeDayDTO;
import com.nineclock.attendance.service.AttendPunchService;
import com.nineclock.common.entity.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping
public class AttendPunchController implements AttendPunchControllerApi {
    @Autowired
    AttendPunchService attendPunchService;

    @Override
    @PostMapping("/punch")
    public Result punch(@RequestBody AttendPunchDTO attendPunchDTO) {
        attendPunchService.punch(attendPunchDTO);
        return Result.success();
    }

    @Override
    @GetMapping("/get")
    public Result<AttendPunchUserWholeDayDTO> queryPunchRecord() {
        AttendPunchUserWholeDayDTO attendPunchUserWholeDayDTO = attendPunchService.queryPunchRecord();
        return Result.success(attendPunchUserWholeDayDTO);
    }

    @Override
    @GetMapping("members")
    public Result<List<AttendPunchDTO>> queryMembers(String startTime, String endTime) {
        List<AttendPunchDTO> attendPunchDTOList = attendPunchService.queryMembers(startTime,endTime);
        return Result.success(attendPunchDTOList);
    }
}
